-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Firestore clone support #9262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Firestore clone support #9262
Conversation
610c8ed
to
224e9f8
Compare
224e9f8
to
9bb892b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits and suggestions, but this mostly lgtm
const helpCommandText = "See firebase firestore:databases:clone --help for more info."; | ||
|
||
if (options.database) { | ||
throw new FirebaseError(`Please do not use --database for this command. ${helpCommandText}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new FirebaseError(`Please do not use --database for this command. ${helpCommandText}`); | |
throw new FirebaseError(`--database is not a supported flag for 'firestoree:databases:clone'. ${helpCommandText}`); |
const targetDatabaseId = targetDatabaseName.databaseId; | ||
const sourceProject = parseDatabaseName(sourceDatabase).projectId; | ||
if (parentProject !== sourceProject) { | ||
throw new FirebaseError(`Source and target projects must match.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new FirebaseError(`Source and target projects must match.`); | |
throw new FirebaseError(`Cloning across projects is not supported.`); |
"block any incoming third-party traffic.", | ||
); | ||
logger.info(); | ||
logger.info(`You can monitor the progress of this clone by executing this command:`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How long is this operation usually? Would it make more sense to just poll on the operation here until it is done?
| UseSourceEncryption | ||
| UseGoogleDefaultEncryption; | ||
|
||
export interface PitrSnapshot { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export interface PitrSnapshot { | |
export interface PITRSnapshot { |
payload, | ||
options, | ||
); | ||
const lro = res.body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to above - we should maybe poll on this using the existing PollOperation utility
Description
Add support for Firestore Database Clone
Scenarios Tested
Sample Commands
firebase firestore:databases:clone projects/myproject/databases/original-db projects/myproject/databases/clone
(chooses most recent available snapshot)firebase firestore:databases:clone projects/myproject/databases/original-db projects/myproject/databases/clone2 --snapshot-time 2025-10-06T10:00:00Z
(uses selected snapshot time)firebase firestore:databases:clone projects/myproject/databases/original-db projects/myproject/databases/db-with-same-encryption --snapshot-time 2025-10-06T10:00:00Z --encryption-type USE_SOURCE_ENCRYPTION
firebase firestore:databases:clone projects/myproject/databases/original-db projects/myproject/databases/db-with-kms-encryption --snapshot-time 2025-10-06T10:00:00Z --encryption-type CUSTOMER_MANAGED_ENCRYPTION --kms-key-name projects/myproject/locations/us-central1/keyRings/testkeyring/cryptoKeys/k1
firebase firestore:databases:clone projects/myproject/databases/original-db projects/myproject/databases/db-with-google-managed-encryption --snapshot-time 2025-10-06T10:00:00Z --encryption-type GOOGLE_DEFAULT_ENCRYPTION